package org.udori.job.helloworld.controller;

import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.validation.BindException;
import org.udori.job.helloworld.model.Employee;

public class EmployeeFieldSetMapper implements FieldSetMapper<Employee> {
	public Employee mapFieldSet(FieldSet fieldSet) throws BindException {
		if (fieldSet == null) return null;
		
		Employee emp = new Employee();
		emp.setEmpId(fieldSet.readInt(0));
		emp.setLastName(fieldSet.readString(1));
		emp.setTitle(fieldSet.readString(2));
		emp.setSalary(fieldSet.readInt(3));
		
		return emp;
	}

}